<html>
<meta charset="utf-8">

<head>
    <script src="jquery-3.2.1.min.js"></script>
    <script>
        $(function () {
            $('button:first').click(function () {
                var b_parent = $('b').parent();
                b_parent.addClass('parent_class');
            });
            $('button:eq(1)').click(function () {
                var b_parent = $('b').parents();
                b_parent.addClass('parent_class');
            });
            $('button:eq(2)').click(function () {
                var b_parent = $('b').parentsUntil('div');
                b_parent.addClass('parent_class');
            });
        });
    </script>
    <style>
        .parent_class {
            border: 3px solid red;
            padding: 2px;
        }
    </style>
</head>
<div>
    <p>遍历--父元素</p>
    <ul>
        <li><b>parent()</b></li>
        <li>parents()</li>
        <li>parentsUntil()</li>
    </ul>
    <button>获取父元素（上一级）parent()</button>
    <button>获取所有父元素parents()</button>
    <button>获取所有父元素parentsUntil('xx') 介于xx之间</button>
</div>

</html>